from django.contrib import admin

from app.admin import FormBaseConfig

from . import models
from .resources import JournalResource, ProjectResource


@admin.register(models.Journal)
class JournalAdmin(FormBaseConfig):

    resource_class = JournalResource  # 导入导出资源类
    list_display = ('id', 'log_date', 'today_work',
                    'tomorrow_plan', 'summary', 'ai_summary_and_suggestions', 'week', 'category')
    list_filter = ('category', 'week', 'log_date')
    list_display_links = ('today_work', 'tomorrow_plan',
                          'summary', 'ai_summary_and_suggestions')
    search_fields = ('today_work', 'tomorrow_plan',
                     'summary', 'ai_summary_and_suggestions')
    readonly_fields = ('created_at', 'created_by',
                       'updated_at', 'updated_by')


@admin.register(models.Project)
class ProjectAdmin(FormBaseConfig):
    resource_class = ProjectResource  # 导入导出资源类
    list_display = ('id', 'name', 'description', 'todo_list')
    list_display_links = ('name', 'description', 'todo_list')
    search_fields = ('name', 'description', 'todo_list')
    readonly_fields = ('created_at', 'created_by',
                       'updated_at', 'updated_by')
